HAL I2C io operation functions migration

This section provides information about the HAL I2C io operation functions migration.

HAL I2C communication in polling mode

HAL1

HAL2

HAL_I2C_Master_Transmit
HAL_I2C_Master_Receive
HAL_I2C_Slave_Transmit
HAL_I2C_Slave_Receive
HAL_I2C_MASTER_Transmit
HAL_I2C_MASTER_Receive
HAL_I2C_SLAVE_Transmit
HAL_I2C_SLAVE_Receive

Related use case: Use case: I2C communication in polling mode


HAL I2C memory write function

HAL1

HAL2

HAL_I2C_Mem_Write
HAL_I2C_Mem_Read
HAL_I2C_IsDeviceReady
HAL_I2C_MASTER_MemWrite
HAL_I2C_MASTER_MemRead
HAL_I2C_MASTER_IsSlaveReady

HAL I2C communication in interrupt mode

HAL1

HAL2

HAL_I2C_Master_Transmit_IT
HAL_I2C_Master_Receive_IT
HAL_I2C_Slave_Transmit_IT
HAL_I2C_Slave_Receive_IT
HAL_I2C_Mem_Write_IT
HAL_I2C_Mem_Read_IT
HAL_I2C_Master_Seq_Transmit_IT
HAL_I2C_Master_Seq_Receive_IT
HAL_I2C_Slave_Seq_Transmit_IT
HAL_I2C_Slave_Seq_Receive_IT
HAL_I2C_EnableListen_IT
HAL_I2C_DisableListen_IT
HAL_I2C_Master_Abort_IT
HAL_I2C_MASTER_Transmit_IT
HAL_I2C_MASTER_Receive_IT
HAL_I2C_SLAVE_Transmit_IT
HAL_I2C_SLAVE_Receive_IT
HAL_I2C_MASTER_MemWrite_IT
HAL_I2C_MASTER_MemRead_IT
HAL_I2C_MASTER_SEQ_Transmit_IT
HAL_I2C_MASTER_SEQ_Receive_IT
HAL_I2C_SLAVE_SEQ_Transmit_IT
HAL_I2C_SLAVE_SEQ_Receive_IT
HAL_I2C_SLAVE_EnableListen_IT
HAL_I2C_SLAVE_DisableListen_IT
HAL_I2C_MASTER_Abort_IT

Related use case: Use case: I2C master transmit/receive in interrupt mode


HAL I2C communication in DMA mode

HAL1

HAL2

HAL_I2C_Master_Transmit_DMA
HAL_I2C_Master_Receive_DMA
HAL_I2C_Slave_Transmit_DMA
HAL_I2C_Slave_Receive_DMA
HAL_I2C_Mem_Write_DMA
HAL_I2C_Mem_Read_DMA
HAL_I2C_Master_Seq_Transmit_DMA
HAL_I2C_Master_Seq_Receive_DMA
HAL_I2C_Slave_Seq_Transmit_DMA
HAL_I2C_Slave_Seq_Receive_DMA
HAL_I2C_MASTER_Transmit_DMA
HAL_I2C_MASTER_Receive_DMA
HAL_I2C_SLAVE_Transmit_DMA
HAL_I2C_SLAVE_Receive_DMA
HAL_I2C_MASTER_MemWrite_DMA
HAL_I2C_MASTER_MemRead_DMA
HAL_I2C_MASTER_SEQ_Transmit_DMA
HAL_I2C_MASTER_SEQ_Receive_DMA
HAL_I2C_SLAVE_SEQ_Transmit_DMA
HAL_I2C_SLAVE_SEQ_Receive_DMA

Related use case: Use case: I2C communication in DMA mode


HAL I2C analog filter configuration

HAL1

HAL2

Functionality:

  • Configure the analog filter for the I2C.

  • Take an I2C handle and an analog filter configuration parameter.

Functionality:

  • Enable the analog filter for the I2C.

  • Take a direct pointer to the I2C registers.

  • Manipulate the I2C control register to enable the analog filter.

HAL_I2CEx_ConfigAnalogFilter
HAL_I2C_EnableAnalogFilter
HAL_I2C_DisableAnalogFilter
HAL_I2C_IsEnabledAnalogFilter

HAL I2C digital filter configuration

HAL1

HAL2

Functionality:

  • Configure the digital filter for the I2C.

  • Take an I2C handle and a digital filter configuration parameter.

Functionality:

  • Set the digital filter for the I2C.

  • Take a direct pointer to the I2C registers and a digital filter configuration parameter.

  • Manipulate the I2C control register to set the digital filter.

HAL_I2CEx_ConfigDigitalFilter
HAL_I2C_SetDigitalFilter

Related concept: Unitary configuration APIs


HAL I2C enable wake up mode

HAL1

HAL2

HAL_I2CEx_EnableWakeUp
HAL_I2C_SLAVE_EnableWakeUp

HAL I2C disable wake up mode

HAL1

HAL2

HAL_I2CEx_DisableWakeUp
HAL_I2C_SLAVE_DisableWakeUp

HAL I2C fast mode plus configuration

HAL1

HAL2

Functionality:

  • Configure the fast mode plus for the I2C with parameter Enable or Disable.

Functionality:

  • Split the function HAL_I2CEx_ConfigFastModePlus in unitary APIs to enable and disable the fast mode plus and the configuration of pin managed by HAL_SYSCFG_EnableI2CFastModePlus and HAL_SYSCFG_DisableI2CFastModePlus. For more details, see: HAL I2C fast mode plus constants

HAL_I2CEx_ConfigFastModePlus
HAL_I2CEx_EnableFastModePlus
HAL_I2CEx_DisableFastModePlus
HAL_I2C_EnableFastModePlus
HAL_I2C_DisableFastModePlus
HAL_I2C_IsEnabledFastModePlus

Related concept: Unitary configuration APIs


HAL I2C autonomous mode

To configure and enable the I2C autonomous mode uses the functions HAL_I2C_AM_SetConfigTrigge and HAL_I2C_AM_EnableTrigger.

HAL1

HAL2

I2C_AutonomousModeConfTypeDef sConfig;

sConfig.TriggerState     = I2C_AUTO_MODE_ENABLE;
sConfig.TriggerSelection = I2C_GRP1_GPDMA_CH0_TCF_TRG;
sConfig.TriggerPolarity  = I2C_TRIG_POLARITY_RISING;

HAL_StatusTypeDef HAL_I2CEx_SetConfigAutonomousMode(I2C_HandleTypeDef *hi2c,
                                           const I2C_AutonomousModeConfTypeDef *sConfig)
hal_i2c_am_trigger_config_t p_config;

p_config.source   = HAL_I2C_AM_TRIGGER_GRP1_GPDMA_CH0_TCF;
p_config.polarity = HAL_I2C_AM_TRIGGER_RISING;

hal_status_t HAL_I2C_AM_SetConfigTrigger(hal_i2c_handle_t *hi2c, const hal_i2c_am_trigger_config_t *p_config);
hal_status_t HAL_I2C_AM_EnableTrigger(hal_i2c_handle_t *hi2c);

Optionally to get the configuration of I2C autonomous mode and disable it, use the functions HAL_I2C_AM_IsEnabledTrigger and HAL_I2C_AM_DisableTrigger.

HAL1

HAL2

HAL_I2CEx_GetConfigAutonomousMode
HAL_I2CEx_ClearConfigAutonomousMode
HAL_I2C_AM_IsEnabledTrigger
HAL_I2C_AM_DisableTrigger